package cn.stronglink.asset.module.datacount.controller;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.plugins.Page;
import cn.stronglink.asset.module.datacount.DataCountService;
import cn.stronglink.asset.module.datacount.vo.CabinetCountDetailVo;
import cn.stronglink.asset.module.datacount.vo.DepartmentInfo;
import cn.stronglink.asset.module.datacount.vo.DirectoryEntity;
import cn.stronglink.asset.module.datacount.vo.ItAssetBrandVo;
import cn.stronglink.asset.module.datacount.vo.SearchDetailParam;
import cn.stronglink.asset.module.datacount.vo.SearchParam;
import cn.stronglink.suite.core.base.AbstractController;

@Controller
@RequestMapping(value = "dataCount")
public class DataCountController extends AbstractController{

	@Autowired
	private DataCountService dataCountService;
	
	/**
	 * 设备类型
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "assetTypeCount")
	public ResponseEntity<ModelMap> assetTypeCount(@RequestBody SearchParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap mapData=dataCountService.getAssetTypeCount(param);
		return setSuccessModelMap(modelMap, mapData);
	}
	
	@RequestMapping(value = "getRoom")
	public ResponseEntity<ModelMap> getRoom(ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		List<DirectoryEntity> mapList=dataCountService.getRoom();
		return setSuccessModelMap(modelMap, mapList);
	}
	
	@RequestMapping(value = "getAssetType")
	public ResponseEntity<ModelMap> getAssetType(ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		List<DirectoryEntity> mapList=dataCountService.getAssetType();
		return setSuccessModelMap(modelMap, mapList);
	}
	
	@RequestMapping(value = "getAssetBrand")
	public ResponseEntity<ModelMap> getAssetBrand(ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		List<DirectoryEntity> mapList=dataCountService.getAssetBrand();
		return setSuccessModelMap(modelMap, mapList);
	}
	
	/**
	 * 设备状态
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "assetStatusCount")
	public ResponseEntity<ModelMap> assetStatusCount(@RequestBody SearchParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap mapData=dataCountService.getAssetStatusCount(param);
		return setSuccessModelMap(modelMap, mapData);
	}
	
	/**
	 * 品牌
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "assetBrandCount")
	public ResponseEntity<ModelMap> assetBrandCount(@RequestBody SearchParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap mapData=dataCountService.getAssetBrandCount(param);
		return setSuccessModelMap(modelMap, mapData);
	}
	
	/**
	 * 领用部门
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "assetDepartCount")
	public ResponseEntity<ModelMap> assetDepartCount(@RequestBody SearchParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap mapData=dataCountService.getAssetDepartCount(param);
		return setSuccessModelMap(modelMap, mapData);
	}
	
	/**
	 * 使用年限统计
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "serviceLifeCount")
	public ResponseEntity<ModelMap> serviceLifeCount(@RequestBody SearchParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap mapData=dataCountService.serviceLifeCount(param);
		return setSuccessModelMap(modelMap, mapData);
	}
	
	/**
	 * 机柜使用情况统计
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "CabinetCount")
	public ResponseEntity<ModelMap> CabinetCount(@RequestBody SearchParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap mapData=dataCountService.CabinetCount(param);
		return setSuccessModelMap(modelMap, mapData);
	}
	
	
	@RequestMapping(value = "getDepartments")
	public ResponseEntity<ModelMap> getDepartments(ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		List<DepartmentInfo> infos=dataCountService.getDepartments();
		return setSuccessModelMap(modelMap, infos);
	}
	@RequestMapping(value = "queryBrandDataDetail")
	public ResponseEntity<ModelMap> queryBrandDataDetail(@RequestBody SearchDetailParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		//List<ItAssetBrandVo> infos=dataCountService.queryBrandDataDetail(param);
		HashMap map=JSON.parseObject(JSON.toJSONString(param),HashMap.class);
		Page<ItAssetBrandVo> page = (Page<ItAssetBrandVo>) super.getPage(map);
		Page<ItAssetBrandVo> data = dataCountService.queryBrandDataDetail(page, param);
		return setSuccessModelMap(modelMap, data);
	}
	
	@RequestMapping(value = "queryDepartDataDetail")
	public ResponseEntity<ModelMap> queryDepartDataDetail(@RequestBody SearchDetailParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap map=JSON.parseObject(JSON.toJSONString(param),HashMap.class);
		Page<ItAssetBrandVo> page = (Page<ItAssetBrandVo>) super.getPage(map);
		Page<ItAssetBrandVo> data = dataCountService.queryDepartDataDetail(page, param);
		return setSuccessModelMap(modelMap, data);
	}
	
	
	@RequestMapping(value = "queryStatusDataDetail")
	public ResponseEntity<ModelMap> queryStatusDataDetail(@RequestBody SearchDetailParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap map=JSON.parseObject(JSON.toJSONString(param),HashMap.class);
		Page<ItAssetBrandVo> page = (Page<ItAssetBrandVo>) super.getPage(map);
		Page<ItAssetBrandVo> data = dataCountService.queryStatusDataDetail(page, param);
		return setSuccessModelMap(modelMap, data);
	}
	
	@RequestMapping(value = "queryTypeDataDetail")
	public ResponseEntity<ModelMap> queryTypeDataDetail(@RequestBody SearchDetailParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap map=JSON.parseObject(JSON.toJSONString(param),HashMap.class);
		Page<ItAssetBrandVo> page = (Page<ItAssetBrandVo>) super.getPage(map);
		Page<ItAssetBrandVo> data = dataCountService.queryTypeDataDetail(page, param);
		return setSuccessModelMap(modelMap, data);
	}
	
	/**
	 * 查询使用年限列表
	 * @param param
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "queryServiceLifeDetail")
	public ResponseEntity<ModelMap> queryServiceLifeDetail(@RequestBody SearchDetailParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap map=JSON.parseObject(JSON.toJSONString(param),HashMap.class);
		Page<ItAssetBrandVo> page = (Page<ItAssetBrandVo>) super.getPage(map);
		Page<ItAssetBrandVo> data = dataCountService.queryServiceLifeDetail(page, param);
		return setSuccessModelMap(modelMap, data);
	}
	
	/**
	 * 机柜容量列表
	 * @param param
	 * @param modelMap
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "queryCabinetCountDetail")
	public ResponseEntity<ModelMap> queryCabinetCountDetail(@RequestBody SearchDetailParam param,ModelMap modelMap, HttpServletRequest request,HttpServletResponse response) {	
		HashMap map=JSON.parseObject(JSON.toJSONString(param),HashMap.class);
		Page<CabinetCountDetailVo> page = (Page<CabinetCountDetailVo>) super.getPage(map);
		Page<CabinetCountDetailVo> data = dataCountService.queryCabinetCountDetail(page, param);
		return setSuccessModelMap(modelMap, data);
	}
}